#include "GroupGameCommand.h"

GroupGameCommand::GroupGameCommand()
{
}

GroupGameCommand::GroupGameCommand(const GroupGameCommand& rhs)
{
	std::list<GameCommand*>::const_iterator it;

	for(it = rhs.commands.begin(); it != rhs.commands.end(); ++it)
	{
		GameCommand *command = (*it);

		commands.push_back( command->Clone() );
	}
}

GroupGameCommand::~GroupGameCommand()
{
	Clear();
}

void GroupGameCommand::Clear()
{
	std::list<GameCommand*>::iterator it;

	for(it = commands.begin(); it != commands.end(); ++it)
	{
		delete (*it);
	}

	commands.clear();
}

void GroupGameCommand::Execute()
{
	std::list<GameCommand*>::iterator it;

	for(it = commands.begin(); it != commands.end(); ++it)
	{
		(*it)->Execute();
	}
}

GameCommand* GroupGameCommand::Clone() const
{
	return new GroupGameCommand(*this);
}

void GroupGameCommand::AddCommand(GameCommand* command)
{
	commands.push_back( command->Clone() );
}

